<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, maximum-scale=1.0" />
    <title>欢迎界面</title>
</head>
<body>
    <div id = "welcome">
        
    </div>  
</body>
<!-- Various Scripts -->
<script src="./js/jquery-3.2.1.min.js"></script>

<script>
    var token = getCookie("token");
    var url = "http://localhost/api/user/info/"+token;
    $.ajax({
                //请求方式
                type : "POST",
                //请求的媒体类型
                contentType: "application/json;charset=UTF-8",
	            url: url,
                data:"",
                success: function(data) {
                    if (data.code == '0000') {
                        $('#welcome').text(data.datas+"，欢迎进入系统");
                    } else {
                        alert("注册失败，原因为："+data.msg);
                    }
                },
                //请求失败，包含具体的错误信息
                error: function(e){
                    alert("注册失败");
                }
        });

   

    function getCookie(objName) {//获取指定名称的cookie的值
        var arrStr = document.cookie.split("; ");
        for (var i = 0; i < arrStr.length; i++) {
            var temp = arrStr[i].split("=");
            if (temp[0] == objName) {
                return decodeURI(temp[1]);
            }
        }
    }

    function getMyCookie(key){
        var val = "";
        // 对cookie操作
        var cookies = document.cookie;
        cookies = cookies.replace(/\s/,"");
        var cookie_array = cookies.split(";");
        for(i=0;i<cookie_array.length;i++){
            // yh_mch=lilei
            var cookie = cookie_array[i];
            var array = cookie.split("=");
            if(array[0]==key){
                val = array[1];
            }
        }
        return val;
    }
</script>

</html>